home *** CD-ROM | disk | FTP | other *** search
- on findpalette castNumber, findCriteria
- if the paramCount < 2 then
- alert("not enough parameters")
- else
- searchCasts(castNumber, findCriteria)
- end if
- end
-
- on findBitdepth castNumber, findCriteria
- if the paramCount < 2 then
- alert("not enough parameters")
- else
- searchCasts(castNumber, findCriteria)
- end if
- end
-
- on searchCasts castNumber, searchCriteria
- set foundMembersList to []
- if castNumber = 0 then
- set firstCast to 1
- set lastCast to the number of castLibs
- else
- set firstCast to castNumber
- set lastCast to castNumber
- end if
- repeat with c = firstCast to lastCast
- repeat with m = 1 to the number of castMembers of castLib c
- set currentMember to member m of castLib c
- if the type of currentMember = #bitmap then
- case 1 of
- ((searchCriteria = 0) or (searchCriteria = #all)):
- add(foundMembersList, currentMember)
- ((searchCriteria > 0) and not symbolp(searchCriteria)):
- if the depth of currentMember = searchCriteria then
- add(foundMembersList, currentMember)
- end if
- ((searchCriteria < 0) and not symbolp(searchCriteria)):
- if the depth of currentMember <> abs(searchCriteria) then
- add(foundMembersList, currentMember)
- end if
- (searchCriteria = #mac):
- if the paletteRef of currentMember = #systemMac then
- add(foundMembersList, currentMember)
- end if
- (searchCriteria = #win):
- if the paletteRef of currentMember = #systemWin then
- add(foundMembersList, currentMember)
- end if
- (searchCriteria = #netscape):
- set currentPalette to the paletteRef of member currentMember
- if not symbolp(currentPalette) then
- if the name of member currentPalette = "netscape" then
- add(foundMembersList, currentMember)
- end if
- end if
- (searchCriteria = #notmac):
- if the depth of member currentMember <> 1 then
- if the paletteRef of currentMember <> #systemMac then
- add(foundMembersList, currentMember)
- end if
- end if
- (searchCriteria = #notwin):
- if the depth of member currentMember <> 1 then
- if the paletteRef of currentMember <> #systemWin then
- add(foundMembersList, currentMember)
- end if
- end if
- (searchCriteria = #notnetscape):
- if the depth of member currentMember <> 1 then
- set currentPalette to the paletteRef of member currentMember
- if not symbolp(currentPalette) then
- if the name of member currentPalette <> "netscape" then
- add(foundMembersList, currentMember)
- end if
- else
- add(foundMembersList, currentMember)
- end if
- end if
- end case
- end if
- end repeat
- end repeat
- if count(foundMembersList) <> 0 then
- outputList(foundMembersList)
- convertList(foundMembersList)
- else
- beep()
- alert("No members were found.")
- end if
- end
-
- on convertList membersList
- set groupByCastList to seperateIntoCast(membersList)
- set rangeList to seperateIntoRanges(groupByCastList)
- set selectionList to makeSelectionList(rangeList)
- makeSelection(selectionList)
- end
-
- on seperateIntoCast membersList
- set groupByCastList to [[]]
- set listIndex to 1
- set previousMember to getAt(membersList, 1)
- repeat with m = 1 to count(membersList)
- set currentMember to getAt(membersList, m)
- set currentCastNumber to getCastNumber(currentMember)
- set previousCastNumber to getCastNumber(previousMember)
- if currentCastNumber = previousCastNumber then
- add(getAt(groupByCastList, listIndex), currentMember)
- else
- set listIndex to listIndex + 1
- addAt(groupByCastList, listIndex, [])
- add(getAt(groupByCastList, listIndex), currentMember)
- end if
- set previousMember to currentMember
- end repeat
- return groupByCastList
- end
-
- on seperateIntoRanges groupByCastList
- set rangeList to []
- repeat with n = 1 to count(groupByCastList)
- set currentList to getAt(groupByCastList, n)
- set range to [getAt(currentList, 1), getAt(currentList, 1)]
- repeat with p = 1 to count(currentList)
- set currentMember to getAt(currentList, p)
- if p < count(currentList) then
- set nextMember to getAt(currentList, p + 1)
- else
- set nextMember to getAt(currentList, p)
- end if
- set currentMemberNumber to getMemberNumber(currentMember)
- set nextMemberNumber to getMemberNumber(nextMember)
- if (currentMemberNumber + 1) = nextMemberNumber then
- setAt(range, 2, nextMember)
- next repeat
- end if
- add(rangeList, range)
- set range to [nextMember, nextMember]
- end repeat
- end repeat
- return rangeList
- end
-
- on makeSelectionList rangeList
- set initMember to getAt(getAt(rangeList, 1), 1)
- set firstCastNumber to getCastNumber(initMember)
- set selectionList to [:]
- setaProp(selectionList, firstCastNumber, [])
- set previousCastNumber to firstCastNumber
- repeat with r = 1 to count(rangeList)
- set currentRange to getAt(rangeList, r)
- set firstMemberNumber to getMemberNumber(getAt(currentRange, 1))
- set lastMemberNumber to getMemberNumber(getAt(currentRange, 2))
- set currentCastNumber to getCastNumber(getAt(currentRange, 1))
- if currentCastNumber = previousCastNumber then
- add(getProp(selectionList, currentCastNumber), [firstMemberNumber, lastMemberNumber])
- next repeat
- end if
- setaProp(selectionList, currentCastNumber, [[firstMemberNumber, lastMemberNumber]])
- set previousCastNumber to currentCastNumber
- end repeat
- return selectionList
- end
-
- on makeSelection selectionList
- repeat with d = 1 to the number of castLibs
- set the selection of castLib d to []
- end repeat
- repeat with c = 1 to count(selectionList)
- set the selection of castLib getPropAt(selectionList, c) to getAt(selectionList, c)
- end repeat
- end
-
- on outputList membersList
- put "Total Members Found:" && count(membersList) & RETURN
- set listOutputString to RETURN & " # Member Name Cast Palette Depth" & RETURN
- repeat with m = 1 to count(membersList)
- set currentMember to getAt(membersList, m)
- set memberNumber to getMemberNumber(currentMember)
- set memberName to the name of member currentMember
- set memberName to padString(memberName, 20)
- set castLibName to the name of castLib getCastNumber(currentMember)
- set castLibName to padString(castLibName, 20)
- set memberPalette to the paletteRef of currentMember
- if symbolp(memberPalette) then
- set memberPalette to string(memberPalette)
- else
- set memberPalette to the name of memberPalette
- end if
- set memberPalette to padString(memberPalette, 10)
- set memberBitDepth to the depth of currentMember
- set memberBitDepth to padString(memberBitDepth, 5)
- case 1 of
- (memberNumber < 10):
- set memberNumber to " " & string(memberNumber)
- (memberNumber < 100):
- set memberNumber to " " & string(memberNumber)
- end case
- put memberNumber & ": " & memberName & " " & castLibName && memberPalette && memberBitDepth & RETURN after listOutputString
- end repeat
- put listOutputString
- end
-
- on padString startString, targetLength
- set newString to startString
- if length(startString) > targetLength then
- set newString to char 1 to targetLength - 3 of startString & "..."
- return newString
- end if
- repeat with n = length(startString) + 1 to targetLength
- put " " after newString
- end repeat
- return newString
- end
-
- on getMemberNumber currentMember
- set memberNumber to word 2 of string(currentMember)
- return value(memberNumber)
- end
-
- on getCastNumber currentMember
- set castNumber to the last word in string(currentMember)
- set castNumber to value(castNumber)
- return castNumber
- end
-